package com.han.jdbc.mybatis._02.plugins;

import java.io.IOException;
import java.io.InputStream;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;

import com.han.jdbc.mybatis._02.mapppers.EmpMapper;
import com.han.jdbc.mybatis.bean.Emp;

/**
* @author hanpeng
* @version 创建时间：2020年7月20日 下午9:12:39
* @ClassName 类名称
* @Description 类描述
*/
public class TestPlugin {
	@Test
	public void testGetEmpByEId() {
		String resource="02mybatis-config-plugin.xml";
		SqlSession sqlSession=null;
		try {
			InputStream is = Resources.getResourceAsStream(resource);
			SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(is);
			sqlSession = sqlSessionFactory.openSession();
			EmpMapper mapper = sqlSession.getMapper(EmpMapper.class);
			Emp emp = mapper.getEmpByEId(1);
			System.out.println(emp);
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			sqlSession.close();
		}
	}
}
